var t = getApp();

Page({
    data: {
        isLoadMore: !0,
        total_page: 0,
        page: 1,
        todayList: [],
        yesterdayList: [],
        monthList: [],
        lastMonthList: [],
        getType: "today",
        total_price: "",
        total: ""
    },
    onLoad: function(t) {
        this.getData();
    },
    swichTabTItem: function(t) {
        var a = t.detail.index;
        this.data.getType = 1 == a ? "yesterday" : 3 == a ? "month" : 2 == a ? "lastMonth" : "today", 
        this.data.isLoadMore = !0, this.data.total_page = 0, this.data.page = 1, this.getData();
    },
    getData: function() {
        var a = this, e = "";
        "today" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.today" : "yesterday" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.yesterday" : "month" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.this-month" : "lastMonth" == this.data.getType && (e = "plugin.store-cashier.frontend.cashier.income.last-month");
        var o = t.getNetAddresss(e);
        t._getNetWork({
            url: o,
            data: {
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? ("today" == a.data.getType ? a.setData({
                    todayList: e.data.data,
                    total_price: e.data.total_price,
                    total: e.data.total
                }) : "yesterday" == a.data.getType ? a.setData({
                    yesterdayList: e.data.data,
                    total_price: e.data.total_price,
                    total: e.data.total
                }) : "month" == a.data.getType ? a.setData({
                    monthList: e.data.data,
                    total_price: e.data.total_price,
                    total: e.data.total
                }) : "lastMonth" == a.data.getType && a.setData({
                    lastMonthList: e.data.data,
                    total_price: e.data.total_price,
                    total: e.data.total
                }), a.setData({
                    total_page: e.data.last_page
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 2e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getMoreData: function() {
        var a = this, e = "";
        if ("today" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.today" : "yesterday" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.yesterday" : "month" == this.data.getType ? e = "plugin.store-cashier.frontend.cashier.income.this-month" : "lastMonth" == this.data.getType && (e = "plugin.store-cashier.frontend.cashier.income.last-month"), 
        this.data.page != this.data.total_page && !(this.data.page >= this.data.total_page)) {
            this.setData({
                page: this.data.page + 1
            });
            var o = t.getNetAddresss(e);
            o += "&page=" + this.data.page, t._getNetWork({
                url: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? "today" == a.data.getType ? a.setData({
                        todayList: a.data.todayList.concat(e.data.data)
                    }) : "yesterday" == a.data.getType ? a.setData({
                        yesterdayList: a.data.yesterdayList.concat(e.data.data)
                    }) : "month" == a.data.getType ? a.setData({
                        monthList: a.data.monthList.concat(e.data.data)
                    }) : "lastMonth" == a.data.getType && a.setData({
                        lastMonthList: a.data.lastMonthList.concat(e.data.data)
                    }) : a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});